<template>
  <div>
    <div v-if="fieldList.length" class="collect-table-list diy-table-width">
      <div v-for="(item,index) in fieldList" :key="index" class="collect-table-item">
        <div class="label">{{ item.columnName }}</div>
        <div class="input-container">
          <el-input-number
            v-model="value[item.columnName]"
            :min="0"
            :max="300"
            :controls="false"
            placeholder="请输入数值比例"
            size="small"
            @change="changeVal" />
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  model: {
    prop: 'value',
    event: 'changeValue'
  },
  props: {
    value: {
      type: Object,
      default: () => {
        return {};
      }
    },
    fieldList: {
      type: Array,
      default: () => {
        return [];
      }
    }
  },
  data() {
    return {
      collectColumnField: []
    };
  },
  methods: {
    setDefault(data) {
      this.collectColumnField = data.collectColumn.field;
    },
    changeVal() {
      this.$emit('changeValue', this.value);
    }
  }
};
</script>

<style lang="scss" scoped>
.collect-table-list {
  border: 1px solid #ddd;
  overflow: hidden;
  display: flex;
  margin-top: 10px;
  border-radius: 4px;
  .collect-table-item {
    border-right: 1px solid #ddd;
    width: 120px;
    flex:1;
    &:last-child {
      border-right: none;
    }
  }
  .label {
    font-size: 14px;
    color: #333;
    line-height: 32px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-bottom: 1px solid #ddd;
    padding: 5px 10px;
  }
  .input-container {
    padding: 5px 10px;
    &::v-deep {
      .el-input {
        width: 100%;
      }
      .el-input__inner {
        border: none;
        font-size: 14px;
        height: 32px;
        padding: 0;
        width: 100% !important;
      }
    }
  }
}
.diy-table-width {
  &::v-deep {
    .el-input-number {
      width: 100%;
      .el-input__inner {
        width: 100%;
        text-align: left;
      }
    }
  }
}
</style>
